package cn.tedu.deviceservice.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

@Component
@Configuration
@EnableSwagger2WebMvc
public class Knife4JConfiguration implements WebMvcConfigurer {
    @Bean
    public Docket createDocket(){
        ApiInfo apiInfo=new ApiInfoBuilder()
                .title("智慧充电设备接口文档")
                .version("v1.0")
                .description("智慧车辆设备接口文档")
                .build();
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo)
                .select()
                .apis(RequestHandlerSelectors.basePackage("cn.tedu.deviceservice.controller"))
                .paths(PathSelectors.any())
                .build();
    }
}
